package com.yanzq;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(HttpServletRequest request){
//        获取请求方式
        String method = request.getMethod();
//        获取所有参数
        String name = request.getParameter("name");
//        获取请求url
        String url = request.getRequestURL().toString();
//        获取协议
        String protocol = request.getProtocol();
//        获取请求头
        String header = request.getHeader("User-Agent");
//        输出所有信息
        return "method:"+method+"<br/>name:"+name+"<br/>url:"+url+"<br/>protocol:"+protocol+"<br/>header:"+header;
    }
}
